﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace ro.fortech.training.mvc.control
{
    public class AccountController
    {               
        public static User userLogged;
        
        public bool Login(string username, string password)
        {
            if (!string.IsNullOrEmpty(username))
            {
                User user = ChangeUser.GetUserByUsername(username);
                if (!string.IsNullOrEmpty(password))
                    if (user.Password == password)
                    {
                        userLogged = user;
                        user.IsLoggedIn = true;
                        return true;
                    }
            }
            return false;
        }

        public bool Logout()
        {
            userLogged.IsLoggedIn = false;
            return true; ;

        }
       
        public void UserWorking(User user)
        {
            User _user = ChangeUser.GetUserByUsername(user.UserName);
           _user.IsWorking = true;
            
        }

        //public void UserNotWorking(User user,TimeSpan time)
        //{
        //    User _user = ChangeUser.GetUserByUsername(user.UserName);
        //    _user.IsWorking =false;
        //    _user.StopWork = time;
 
        //}
       
    }
}
